﻿using System;
using System.Collections.Generic;
using Windows.UI.Xaml.Controls;


// The Grouped Items Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234231

namespace Mandoo
{
    /// <summary>
    /// A page that displays a grouped collection of items.
    /// </summary>
    public sealed partial class DashBoard : Mandoo.Common.LayoutAwarePage
    {
        public DashBoard()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            // TODO: Assign a collection of bindable groups to this.DefaultViewModel["Groups"]
            PopulateMenu();
        }

        private void PopulateMenu()
        {
            List<Menu> Menus = new List<Menu>();
            DateTime startDate = DateTime.Now;

            Menu menu = new Menu();
            menu.Title = "contactos";
            /*menu.MenuOptions.Add(new MenuOption() { Title = "agenda"});
            menu.MenuOptions.Add(new MenuOption() { Title = "importar"});*/
            menu.MenuOptions.Add(new MenuOption() { Title = "importar desde contacts", Xaml = "ImportFromContacts" });
            /*menu.MenuOptions.Add(new MenuOption() { Title = "importar desde outlook" });
            menu.MenuOptions.Add(new MenuOption() { Title = "grupos"});*/
            Menus.Add(menu);

            menu = new Menu();
            menu.Title = "cuenta";
           // menu.MenuOptions.Add(new MenuOption() { Title = "perfil"});
            menu.MenuOptions.Add(new MenuOption() { Title = "desconectar", Xaml = "Logout" });
          /*  menu.MenuOptions.Add(new MenuOption() { Title = "contratar"});
            menu.MenuOptions.Add(new MenuOption() { Title = "biblioteca"});
            menu.MenuOptions.Add(new MenuOption() { Title = "ayuda"});
            */
            Menus.Add(menu);

            menu = new Menu();
            menu.Title = "doSMS";
            menu.MenuOptions.Add(new MenuOption() { Title = "nuevo", Xaml = "NewSMS"});
            /*menu.MenuOptions.Add(new MenuOption() { Title = "historial"});
            menu.MenuOptions.Add(new MenuOption() { Title = "estadisticas"});
            menu.MenuOptions.Add(new MenuOption() { Title = "campañas"});
            menu.MenuOptions.Add(new MenuOption() { Title = "ajustes"});
            menu.MenuOptions.Add(new MenuOption() { Title = "descargar"});*/
            Menus.Add(menu);
            /*
            menu = new Menu();
            menu.Title = "doForms";
            menu.MenuOptions.Add(new MenuOption() { Title = "nuevo"});
            menu.MenuOptions.Add(new MenuOption() { Title = "formularios"});
            menu.MenuOptions.Add(new MenuOption() { Title = "informes"});
            Menus.Add(menu);


            menu = new Menu();
            menu.Title = "doMail";
            menu.MenuOptions.Add(new MenuOption() { Title = "nuevo"});
            menu.MenuOptions.Add(new MenuOption() { Title = "historial"});
            menu.MenuOptions.Add(new MenuOption() { Title = "estadisticas"});
            menu.MenuOptions.Add(new MenuOption() { Title = "campañas"});
            menu.MenuOptions.Add(new MenuOption() { Title = "ajustes"});
            Menus.Add(menu);


            menu = new Menu();
            menu.Title = "doBot";
            menu.MenuOptions.Add(new MenuOption() { Title = "nuevo"});
            menu.MenuOptions.Add(new MenuOption() { Title = "tareas"});
            menu.MenuOptions.Add(new MenuOption() { Title = "informes"});
            menu.MenuOptions.Add(new MenuOption() { Title = "twitter"});
            menu.MenuOptions.Add(new MenuOption() { Title = "facebook"});
            menu.MenuOptions.Add(new MenuOption() { Title = "google"});
            menu.MenuOptions.Add(new MenuOption() { Title = "linkedn"});
            menu.MenuOptions.Add(new MenuOption() { Title = "pinterest"});
            Menus.Add(menu);

            menu = new Menu();
            menu.Title = "doDeals";
            menu.MenuOptions.Add(new MenuOption() { Title = "nueva"});
            menu.MenuOptions.Add(new MenuOption() { Title = "historial"});
            menu.MenuOptions.Add(new MenuOption() { Title = "informes"});
            menu.MenuOptions.Add(new MenuOption() { Title = "balance"});
            menu.MenuOptions.Add(new MenuOption() { Title = "validar"});
            Menus.Add(menu);
            */

            groupedItemsViewSource.Source = Menus;
        }

        private void itemGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            int index = ((GridView)sender).Items.IndexOf(e.ClickedItem);
            MenuOption menuOption = (MenuOption)((GridView)sender).Items[index];
            
            switch(menuOption.Xaml)
            {
                case "NewSMS":
                    Frame.Navigate(typeof(NewSMS));
                    break;
                case "Logout":
                    Frame.Navigate(typeof(Login));
                    break;
                case "ImportFromContacts":
                    Frame.Navigate(typeof(ImportFromContacts));
                    break;
            }
        }

    }
}
